<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<script type="text/javascript">
			//根据课件动物类的例子，尝试动物飞的方法，然后子类进行重写，实现多态。
			function Animal(type){
				this.type = type;
			}
			Animal.prototype.Fly = function(){
				console.log(this.type + "会飞");
			}
			function F(){}
			F.prototype = Animal.prototype;
			//鸟类
			function Bird(){
				Animal.call(this,"鸟");
			}
			Bird.prototype = new F();
			Bird.prototype.constructor = Bird;
			Bird.prototype.Fly = function(){
				console.log(this.type + "会用带羽毛的翅膀飞");
			}
			var bird = new Bird();
			bird.Fly();
			//蝴蝶类
			function Butterfly(){
				Animal.call(this,"蝴蝶");
			}
			Butterfly.prototype = new F();
			Butterfly.prototype.constructor = Butterfly;
			Butterfly.prototype.Fly = function(){
				console.log(this.type + "会用漂亮的翅膀飞");
			}
			var butterfly = new Butterfly();
			butterfly.Fly();
			//蜜蜂类
			function Bee(){
				Animal.call(this,"蜜蜂");
			}
			Bee.prototype = new F();
			Bee.prototype.constructor = Bee;
			Bee.prototype.Fly = function(){
				console.log(this.type + "会用透明的翅膀飞");
			}
			var bee = new Bee();
			bee.Fly();
		</script>
	</body>
</html>
